class Person:
    def __init__(self,name):
        self.name = name

    def feed_pet(self,pet):# pet既可以接收cat,也可以接收dog,也可以接收tiger
        # isinstance(obj,类) --> 判断obj是否是类的对象或者判断obj是否是类的子类的对象
        if isinstance(pet,Pet):
            print('{}喜欢养宠物:{},昵称是:{}'.format(self.name,pet.role,pet.nickname))
        else:
            print('不是宠物类型。。。')

class Pet:
    role = 'pet'
    def __init__(self,nickname,age):
        self.nickname = nickname
        self.age = age

    def show(self):
        print('宠物昵称:{},年龄:{}'.format(self.nickname,self.age))

class Cat(Pet):
    role = 'cat'
    def catch_mouse(self):
        print('抓老鼠')

class Dog(Pet):
    role = 'dog'
    def watch_house(self):
        print('看家')

class Tiger:
    def eat(self):
        print('吃人')

cat = Cat('小花',2)
dog = Dog('旺财',3)

tiger = Tiger()

person = Person('小明')

person.feed_pet(cat)

person = Person('小红')
person.feed_pet(tiger)









